home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr30
/
hercb21.zip
/
TESTPIX.C
< prev
next >
Wrap
Text File
|
1993-05-03
|
5KB
|
232 lines
/**********************************************************************
*
* TEST / DEMO PROGRAM FOR HERCBIOS
* Dave Tutelman - August 1988
*
* This program has the purposes of:
* - Testing HERCBIOS on your machine.
* - Demonstrating how to program using HERCBIOS.
* It uses a "library" of utility routines in HERCPIXL.C.
*
* TESTPIX.C is written in pretty standard C, so it should be
* independent of which brand of C compiler you use
* (though I've only tested it with Borland's Turbo C).
*/
#include <stdio.h>
#define HERC29 8 /* 29 x 90 Hercules mode */
#define HERC43 9 /* 43 x 90 Hercules mode */
#define NORM 0x07 /* normal video */
#define UNDER 0x01 /* underscore */
#define REVERSE 0x70 /* reverse video */
#define INVIS 0x00 /* invisible */
/* set up a graphic character table for hyper-ASCII */
char graf_tbl [5][8] =
{ { 0x00, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38 },
{ 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38 },
{ 0xFF, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7 },
{ 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF },
{ 0x03, 0x07, 0x0E, 0x1C, 0x38, 0x70, 0xE0, 0xC0 } };
main (argc,argv)
int argc;
char *argv[];
{
unsigned int i,j;
unsigned int f,g;
int mode;
int ht,wid;
int rows;
/* check mode argument */
if (argc != 2)
quitmsg();
mode = atoi (argv[1]); /* i = video mode */
switch (mode) {
case 4: /* 320 x 200 CGA */
case 5:
ht = 200;
wid = 320;
f=20; g=32;
rows = 25;
break;
case 6: /* 640 x 200 CGA */
ht = 200;
wid = 640;
f=20;g=64;
rows = 25;
break;
case HERC29:
ht = 348;
wid = 720;
f=35;g=72;
rows = 29;
break;
case HERC43:
ht = 348;
wid = 720;
f=35;g=72;
rows = 43;
break;
default:
quitmsg ();
break;
}
/* set up the int 1F vector to point to bullseye */
poke (0, 4*0x1F, graf_tbl);
poke (0, 4*0x1F +2, _DS);
grafix (mode);
/* now draw a couple of lines */
for (i=0; i<wid; i++)
{
j = (i * f) / g;
if (j >= ht) break;
pixel (i, j, 1);
pixel (i, ht - j, 1);
}
j=getchar(); /* wait for CR */
/* a different pattern on page 1 */
if (mode > 6) /* can't do it for emulated CGA */
swpage (1);
f = wid / 8;
g = ht / 6;
for (i=0; i<wid; i++)
for (j=0; j<ht; j=j+g)
pixel (i,j,1);
for (i=0; i<wid; i=i+f)
for (j=0; j<ht; j++)
pixel (i,j,1);
if (mode > 6) {
/* switch back and forth a couple of times */
j=getchar();
swpage (0);
j=getchar();
swpage (1);
}
/* add some writing */
j=getchar();
setattr (NORM);
dline (10, 2, "Hello, there!");
dline (10, 3, "Second LINE of text.");
dline (10, 4, "All on display page 1.");
j=getchar();
charset();
if (mode > 6) {
/* repeat for page 0 */
j=getchar();
swpage (0);
/* add some writing */
dline (10, 2, "Hello, there!");
dline (10, 3, "Second LINE of text.");
dline (10, 4, "this time on display page 0.");
}
/* Check two "obscure" features:
* multiple character write & custom character table.
*/
j = getchar();
setattr (UNDER);
for (j=0; j<5; j++)
nchar (44, 14+j, 0x80+j, 16);
setattr (REVERSE);
for (j=0; j<5; j++)
nchar (44, 19+j, 0x80+j, 16);
/* Create a scroll area, and scroll it a couple of times */
j=getchar();
if ((mode==HERC29) || (mode==HERC43))
setattr (REVERSE);
else setattr (NORM);
for (i=0; i<16; i++)
for (j=0; j<32; j++)
dchar (j+4, i+6, (char) i + 'A');
j=getchar();
scroll (7,5, 20,34, 1,NORM);
j=getchar();
scroll (7,5, 20,34, 1,NORM);
j=getchar();
scroll (7,5, 20,34, -1,REVERSE);
j=getchar();
scroll (7,5, 20,34, -1,REVERSE);
/* And a blanked-out "scroll area" */
j=getchar();
scroll (9,9, 18,30, 0, NORM);
/* Test TTY write and "automatic" full-screen scroll */
j = getchar();
dchar (0,rows-6, 2);
for (i=0; i<6; i++) {
for (j=0; j<100; j++)
hputc ((char)i + 'A');
hputc ('\n');
}
/* back to alpha mode */
j = getchar();
alfa();
}
/**********************************************************************/
charset () /* show the whole character set in all colors */
{
setattr (NORM); charset_1 (6,4);
setattr (UNDER); charset_1 (10,4);
setattr (INVIS); charset_1 (14,4);
setattr (REVERSE); charset_1 (18,4);
setattr (NORM);
}
charset_1 (y,x) /* show the whole character set in one color */
int y,x;
{
int i,j;
for (i=0; i<4; i++)
for (j=0; j<32; j++)
dchar (j+x, i+y, (char) (32*i+j));
}
dline (x, y, chstr) /* write character-string at x,y */
int x,y;
char chstr [90];
{
int i;
char *p;
i=0;
for ( p=chstr; *p != '\0'; p++ )
{
dchar ( x+i, y, *p );
i++;
}
}
/***************************************************************/
quitmsg()
{
puts("usage: testpix <valid graphics mode>\n");
exit (-1);
}